/*********************************************************************
	Rhapsody	: 7.6
	Login		: Pawel
	Component	: DefaultComponent
	Configuration 	: DefaultConfig
	Model Element	: Alarm
//!	Generated Date	: Sun, 27, Nov 2011 
	File Path	: DefaultComponent/DefaultConfig/CargoLiftSystem/Alarm.java
*********************************************************************/

package CargoLiftSystem;

//## link itsIAlarm 
import Hardware.IAlarm;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.*;
//## auto_generated
import com.ibm.rational.rhapsody.animation.*;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.states.*;
//## auto_generated
import com.ibm.rational.rhapsody.animcom.animMessages.*;

//----------------------------------------------------------------------------
// CargoLiftSystem/Alarm.java                                                                  
//----------------------------------------------------------------------------

//## package CargoLiftSystem 


//## class Alarm 
public class Alarm implements RiJStateConcept, Animated {
    
    //#[ ignore
    // Instrumentation attributes (Animation)
    private Animate animate;
    
    public static AnimClass animClassAlarm = new AnimClass("CargoLiftSystem.Alarm",false);
    //#]
    
    public Reactive reactive;		//## ignore 
    
    protected IAlarm itsIAlarm;		//## link itsIAlarm 
    
    protected Lift itsLift;		//## link itsLift 
    
    
    //## statechart_method 
    public RiJThread getThread() {
        return reactive.getThread();
    }
    
    //## statechart_method 
    public void schedTimeout(long delay, long tmID, RiJStateReactive reactive) {
        getThread().schedTimeout(delay, tmID, reactive);
    }
    
    //## statechart_method 
    public void unschedTimeout(long tmID, RiJStateReactive reactive) {
        getThread().unschedTimeout(tmID, reactive);
    }
    
    //## statechart_method 
    public RiJEventConsumer getEventConsumer() {
        return (RiJEventConsumer)reactive;
    }
    
    //## statechart_method 
    public void gen(RiJEvent event) {
        reactive._gen(event);
    }
    
    //## statechart_method 
    public void queueEvent(RiJEvent event) {
        reactive.queueEvent(event);
    }
    
    //## statechart_method 
    public int takeEvent(RiJEvent event) {
        return reactive.takeEvent(event);
    }
    
    // Constructors
    
    //## auto_generated 
    public  Alarm(RiJThread p_thread) {
        try {
            animInstance().notifyConstructorEntered(animClassAlarm.getUserClass(),
               new ArgData[] {
               });
        
        reactive = new Reactive(p_thread);
        initRelations(p_thread);
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## auto_generated 
    public IAlarm getItsIAlarm() {
        return itsIAlarm;
    }
    
    //## auto_generated 
    public void setItsIAlarm(IAlarm p_IAlarm) {
        itsIAlarm = p_IAlarm;
        if(p_IAlarm != null)
            {
                animInstance().notifyRelationAdded("itsIAlarm", p_IAlarm);
            }
        else
            {
                animInstance().notifyRelationCleared("itsIAlarm");
            }
    }
    
    //## auto_generated 
    public Lift getItsLift() {
        return itsLift;
    }
    
    //## auto_generated 
    public void __setItsLift(Lift p_Lift) {
        itsLift = p_Lift;
        if(p_Lift != null)
            {
                animInstance().notifyRelationAdded("itsLift", p_Lift);
            }
        else
            {
                animInstance().notifyRelationCleared("itsLift");
            }
    }
    
    //## auto_generated 
    public void _setItsLift(Lift p_Lift) {
        if(itsLift != null)
            {
                itsLift.__setItsAlarm(null);
            }
        __setItsLift(p_Lift);
    }
    
    //## auto_generated 
    public Lift newItsLift(RiJThread p_thread) {
        itsLift = new Lift(p_thread);
        itsLift._setItsAlarm(this);
        animInstance().notifyRelationAdded("itsLift", itsLift);
        return itsLift;
    }
    
    //## auto_generated 
    public void deleteItsLift() {
        itsLift.__setItsAlarm(null);
        animInstance().notifyRelationRemoved("itsLift", itsLift);
        itsLift=null;
    }
    
    //## auto_generated 
    protected void initRelations(RiJThread p_thread) {
        itsLift = newItsLift(p_thread);
    }
    
    //## auto_generated 
    public boolean startBehavior() {
        boolean done = true;
        done &= itsLift.startBehavior();
        done &= reactive.startBehavior();
        return done;
    }
    
    //## ignore 
    public class Reactive extends RiJStateReactive implements AnimatedReactive {
        
        // Default constructor 
        public Reactive() {
            this(RiJMainThread.instance());
        }
        
        
        // Constructors
        
        public  Reactive(RiJThread p_thread) {
            super(p_thread);
        }
        
        /**  methods added just for design level debugging instrumentation */
        public boolean startBehavior() {
            try {
              animInstance().notifyBehavioralMethodEntered("startBehavior",
                  new ArgData[] {
                   });
              return super.startBehavior();
            }
            finally {
              animInstance().notifyMethodExit();
            }
        }
        public int takeEvent(RiJEvent event) { 
            try { 
              //animInstance().notifyTakeEvent(new AnimEvent(event));
              animInstance().notifyBehavioralMethodEntered("takeEvent",
                  new ArgData[] { new ArgData(RiJEvent.class, "event", event.toString())
                   });
              return super.takeEvent(event); 
            }
            finally { 
              animInstance().notifyMethodExit();
            }
        }
        /**  see com.ibm.rational.rhapsody.animation.AnimatedReactive interface */
        public AnimInstance animInstance() { 
            return Alarm.this.animInstance(); 
        }
        
    }
    //#[ ignore
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public AnimClass getAnimClass() { 
        return animClassAlarm; 
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public Object getFieldValue(java.lang.reflect.Field f, Object userInstance) { 
         Object obj = null;
         try {
             obj = f.get(userInstance);
         } catch(Exception e) {
              System.err.println("Exception: getting Field value: " + e);
              e.printStackTrace();
         }
         return obj;
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public AnimInstance animInstance() {
        if (animate == null) 
            animate = new Animate(); 
        return animate; 
    } 
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public void addAttributes(AnimAttributes msg) {
        
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public void addRelations(AnimRelations msg) {
        
        msg.add("itsLift", true, true, itsLift);
        msg.add("itsIAlarm", false, true, itsIAlarm);
    }
    /** An inner class added as instrumentation for animation */
    public class Animate extends AnimInstance { 
        public  Animate() { 
            super(Alarm.this); 
        } 
        public void addAttributes(AnimAttributes msg) {
            Alarm.this.addAttributes(msg);
        }
        public void addRelations(AnimRelations msg) {
            Alarm.this.addRelations(msg);
        }
        
    } 
    //#]
    
}
/*********************************************************************
	File Path	: DefaultComponent/DefaultConfig/CargoLiftSystem/Alarm.java
*********************************************************************/

